extern "C" {
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
#include <stdlib.h>
#include <iostream>
using namespace std;

#define root_dir "/Volumes/MacAPPS/Development/brick-and-blast/data"
#define resource_scanner_script "resource_scanner.lua"

int main (int argc, char** argv) {
  lua_State* L = luaL_newstate();

  luaL_openlibs(L);

  if (luaL_dofile(L, resource_scanner_script)) {
    cerr << "Unable to open script file : " << resource_scanner_script << endl;
    cerr << "Lua reported : " << lua_tostring(L, -1) << endl;
    exit(EXIT_FAILURE);
  }

  lua_getglobal(L, "scan_resources");
  lua_pushstring(L, root_dir);
  lua_call(L, 1, 1);

  lua_pushnil(L);
  while (lua_next(L,-2) != 0) {
    cout << lua_tostring(L, -2);
    cout << " " << lua_tostring(L, -1) << endl;
    lua_pop(L, 1);
  }

  exit(EXIT_SUCCESS);
}

